package interceptcrossing.ui.command;

import interceptcrossing.Intercept;
import interceptcrossing.command.Command;
import interceptcrossing.ui.MainWindowDirector;

public class AddInterceptCommand implements Command {

	private MainWindowDirector windowDirector;
	private Intercept intercept;

	public AddInterceptCommand(MainWindowDirector windowDirector, Intercept intercept) {
		if (windowDirector == null) {
			throw new NullPointerException("Main window director cannot be null");
		}

		if (intercept == null) {
			throw new NullPointerException("Intercept cannot be null");
		}

		this.windowDirector = windowDirector;
		this.intercept = intercept;
	}

	public void doCommand() {
		windowDirector.addIntercept(this.intercept);
	}

	public String getDescription() {
		return "Добавление отрезка " + this.intercept.toString();
	}

	public void undoCommand() {
		windowDirector.removeIntercept(this.intercept);
	}
}
